﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.BIZ;
namespace AnyOffice.general.email
{
    public partial class inbox_read_detail : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                int emailId = (Request.QueryString["email_id"] == null) ? 0 : int.Parse(Request.QueryString["email_id"].ToString());
                this.ViewState["email_id"] = emailId;
                int num2 = (Request.QueryString["box_id"] == null) ? 0 : int.Parse(Request.QueryString["box_id"].ToString());
                this.ViewState["box_id"] = num2;
                int num3 = (Request.QueryString["page"] == null) ? 1 : int.Parse(Request.QueryString["page"].ToString());
                this.ViewState["page"] = num3;
                DataTable table = new EmailDao().SelectByEmailId(base.Conn, emailId, base.User.Identity.Name);
                if (table.Rows.Count > 0)
                {
                    if (Convert.ToBoolean(table.Rows[0]["ReadFlag"].ToString()))
                    {
                        this.litReadFlag.Text = "<img title='已读' src='/images/email_open.gif' border='0' align='absmiddle'>";
                    }
                    else
                    {
                        this.litReadFlag.Text = "<img title='未读' src='/images/email_close.gif' border='0' align='absmiddle'>";
                    }
                    this.litSubject.Text = (table.Rows[0]["Subject"].ToString() == string.Empty) ? "[无主题]" : table.Rows[0]["Subject"].ToString();
                    this.litFromName.Text = StringHelper.GetUserNames(base.Conn, table.Rows[0]["FromId"].ToString());
                    if (table.Rows[0]["ToId"] != DBNull.Value)
                    {
                        this.litToName.Text = StringHelper.GetUserNames(base.Conn, table.Rows[0]["ToId2"].ToString());
                    }
                    if (table.Rows[0]["CopyToId"] != DBNull.Value)
                    {
                        this.litCopyToName.Text = "抄送：" + StringHelper.GetUserNames(base.Conn, table.Rows[0]["CopyToId"].ToString()) + "<br />";
                    }
                    switch (Convert.ToInt32(table.Rows[0]["Important"].ToString()))
                    {
                        case 1:
                            this.litImportant.Text = "<span class=\"TextColor1\">重要</span>";
                            break;

                        case 2:
                            this.litImportant.Text = "<span class=\"TextColor1\">非常重要</span>";
                            break;
                    }
                    this.litSendTime.Text = table.Rows[0]["SendTime"].ToString();
                    this.litContent.Text = (table.Rows[0]["Content"] != DBNull.Value) ? table.Rows[0]["Content"].ToString() : "";
                    string attachmentId = (table.Rows[0]["AttachmentId"] != DBNull.Value) ? table.Rows[0]["AttachmentId"].ToString() : "";
                    if ((this.litAttachment.Text = AttachmentBiz.Display(base.Conn, attachmentId)) == string.Empty)
                    {
                        this.litAttachment.Text = "无";
                    }
                }
            }
        } 

    }
}
